<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>你站的足够高了吗</title>
  <style>
    * {
      margin: 0;
    }


    section {
      position: absolute;
      width: 80vw;
      height: 70vh;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      background: #ad6989;
      border-radius: 50px 100px / 120px;
    }

    p {
      position: absolute;
      width: 50vw;
      height: 40vh;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      text-align: center;
      padding: 10px 50px 0 25px;
      background: #ffa299;
      border-radius: 50px 100px / 120px;
    }

    .app {
      width: 100vw;
      height: 100vh;
      background: #562349;
      position: relative;
    }

    .span {
      position: absolute;
      width: 30vw;
      height: 20vh;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      line-height: 20vh;
      text-align: center;
      background: #fee2b3;
      border-radius: 50px 100px / 120px;
      font-size: larger;
      font-weight: 800;
    }

    .daySpan {
      background: #204051;
      color: antiquewhite;
    }

    .hourSpan {
      background: #3b6978;
      color: antiquewhite;
    }

    .minuteSpan {
      background: #84a9ac;
      color: antiquewhite;
    }

    .secondSpan {
      background: #cae8d5;
      color: antiquewhite;
    }
  </style>
</head>

<body>
  <div class="app">
    <section>
      <p>东坡有云“三月七日，沙湖道中遇雨。雨具先去，同行皆狼狈，余独不觉，已而遂晴，故作此。
        莫听穿林打叶声，何妨吟啸且徐行。竹杖芒鞋轻胜马，谁怕？一蓑烟雨任平生。
        料峭春风吹酒醒，微冷，山头斜照却相迎。回首向来萧瑟处，归去，也无风雨也无晴。”</p>
      <div class="span">
        <span class="daySpan"></span>
        <span class="hourSpan"></span>
        <span class="minuteSpan"></span>
        <span class="secondSpan"></span>
      </div>
    </section>
  </div>

  <script>
    const daySpan = document.querySelector('.daySpan'),
      hourSpan = document.querySelector('.hourSpan'),
      minuteSpan = document.querySelector('.minuteSpan'),
      secondSpan = document.querySelector('.secondSpan'),
      deadline = Date.parse('2022-8-31 23:50:00')

    function timedown() {
      // console.log(deadline);
      const now = Date.now(), timeRemainning = deadline - now
      let day, hour, minute, second
      if (timeRemainning < 0) return 0

      second = Math.floor(timeRemainning / 1000 % 60)
      minute = Math.floor(timeRemainning / 1000 / 60 % 60)
      hour = Math.floor(timeRemainning / 1000 / 60 / 60 % 24)
      day = Math.floor(timeRemainning / 1000 / 60 / 60 / 24)

      daySpan.innerHTML = day + '天'
      hourSpan.innerHTML = hour + '时'
      minuteSpan.innerHTML = minute + '分'
      secondSpan.innerHTML = second + '秒'

      setTimeout(timedown, 1000)
    }

    timedown()
  </script>
</body>

</html>